import { ref } from "vue";
import type { Code, CodeParams } from "@/types/loginTypes";
import { sendCodeAPI } from "@/api/userApi.ts";

const useSendCode = () => {

    const code = ref<string>("");

    const sendCode = async (params: CodeParams): Promise<void> => {
        const { data }: { data: Code } = await sendCodeAPI(params);
        code.value = data.code;
    };

    return {
        code,
        sendCode,
    };

};


export default useSendCode;
